package com.tanhua.server.controller;

import com.tanhua.model.vo.SoundVo;
import com.tanhua.server.service.PeachBlossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class PeachBlossomController {

    @Autowired
    private PeachBlossomService peachBlossomService;

    /**
     * 桃花传音-发送语音
     * POST/peachblossom
     */
    @PostMapping
    public ResponseEntity sendSound(@RequestBody MultipartFile soundFile) throws IOException {
        peachBlossomService.sendSound(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接受语音
     * GET/peachblossom
     */
    @GetMapping
    public ResponseEntity getSound() {
        SoundVo vo = peachBlossomService.getSound();
        return ResponseEntity.ok(vo);
    }
}
